(function() {
    let curIndex = location.search.substring(1).split('=')[1];
    console.log(curIndex);
    fetch('http://chst.vip:1234/api/getdiscountproduct?productid=' + curIndex).then(body => body.json()).then(res => {
        let result = res.result;
        let nrStr = '';
        result.forEach(item => {
            nrStr += `
            <h2>${item.productName}</h2>
            <span>上新时间: ${item.productTime}</span>
            <span>来源: ${item.productFrom}</span>
            <div class="content">
                <div class="img">${item.productImg}</div>
                <h4>¥ ${item.productPrice}</h4>
                <div class="info">
                    <p>${item.productInfo}</p>
                </div>
            </div>
            <div class="buy">
                <button id="shopping">前往购买</button>
                <img src="../images/ewm.png" alt="" class="ewm">
            </div>
            ${item.productComment}
            `
        });
        $('main').html(nrStr)
    })
})()